$(function () {
    obj.init();
});

var obj = new JsFun();
function JsFun() {
    return {
        dataGrid: null,
        dom: {
            search: null
        },
        comId: null,
        init: function () {
            this.comId  = xhTool.getQuery('comId');
            $('#list_search_startTime').datebox({width: 95});
            $('#list_search_endTime').datebox({width: 95});
            this.dataGrid = new xhDataGrid($('#list'), 'res/getReferenceApply', {comId: this.comId});
            this.dataGrid.parseToolbar().init().activeButton(['bt_list_repeal', 'bt_list_del'],
                ['bt_list_progress', 'bt_list_planApply', 'bt_list_planDetail', 'bt_list_refuseHandle', 'bt_list_refuseCommit',
                'bt_list_checkTypeIn', 'bt_list_showDetail']);
            this.dom.search = $('#bt_list_search');
            $('#bt_list_check').menubutton({
                menu: '#menu_referenceCheck'
            });
            xhExtra.clearLoadSuccess(this.dataGrid);
            this.listener();
        },
        listener: function () {
            var $this = this;
            //查询
            $this.dom.search.click(function () {
                $this.funObj().search();
            });
            xhTool.bindDocKeyDown($this.dom.search);
            //获取区域数据
            $('#school_area').combotree({
                url: 'getDepData',
                animate:true,
                onLoadSuccess:function(node,data){
                    $length = data.length;
                    $.each(data,function (id,value) {
                        if (value.children !== undefined) {
                            $length = $length + value.children.length;
                        }
                    })
                },
                onShowPanel:function(){
                    if ($length <= 8){
                        $(this).combobox('panel').height("auto");//高度自适应
                    }else{
                        $(this).combobox('panel').height("200");//高度自定义
                    }
                },
                onBeforeSelect: function (node) {
                    var t = $(this).tree;
                    var isLeaf = t('isLeaf', node.target);
                    if (!isLeaf) {//选择的不是叶子节点
                        return false;
                    }
                }
            });
            //双击
            this.dataGrid.onDblClickRow = function(rowIndex, rowData){
                var id = rowData['iId'];
                var status = rowData['iStatusName'];
                var createId = rowData['iCreateUserId'];
                var button = '';
                var check = $('#check_data').val();
                var edit = $('#edit_data').val();
                var userId = $('#userId_data').val();
                if (id.length <= 0) {
                    window.top.xhTop.showError('未选中记录！');
                    return false;
                }

                if (edit == 2 && check == 2){
                    button = '保存';
                } else if (edit == 2 && check == 1){
                    if ((status === '待审核' || status === '拒绝' || status === '待定') && createId == userId){
                        button = '保存';
                    }
                }
                window.top.xhTop.showModal({
                    title: '申请信息：编号'+id,
                    content: xhTool.getFrameString('res/showModifyRefApply', {id:id}, 600),
                    button: button,
                    size: 'lg',
                    width:'950'
                });
            };
            //撤销关联教师
            $('#bt_list_repeal').click(function(){
                if(xhExtra.buttonDisabled($(this))) return false;
                $this.funObj().repeal();
            });
            //取消申请
            $('#bt_list_del').click(function(){
                if(xhExtra.buttonDisabled($(this))) return false;
                $this.funObj().delApply();
            });
            // //增加
            // $('#bt_list_add').click(function(){
            //     if(xhExtra.buttonDisabled($(this))) return false;
            //     $this.funObj().addApply();
            // });
            //查看审核详情
            $('.xh-datagrid').on('click','.checkResult',function () {
                var checkResult=$(this).attr('checkResult');
                window.top.xhTop.showMessage({
                    title: '[审核详情]',
                    text: checkResult
                });
            });
            //查看进度
            $('#bt_list_progress').click(function(){
                if(xhExtra.buttonDisabled($(this))) return false;
                $this.funObj().showProgress();
            });
            //排期申请
            $('#bt_list_planApply').click(function(){
                if(xhExtra.buttonDisabled($(this))) return false;
                $this.funObj().planApply();
            });
            //排期计划
            $('#bt_list_planDetail').click(function(){
                if(xhExtra.buttonDisabled($(this))) return false;
                $this.funObj().planDetail();
            });
            //刷新录入状态
            $('#bt_list_refresh').click(function(){
                if(xhExtra.buttonDisabled($(this))) return false;
                $this.funObj().refreshPublish();
            });
            //拒绝处理
            $('#bt_list_refuseHandle').click(function(){
                if(xhExtra.buttonDisabled($(this))) return false;
                $this.funObj().refuseHandle();
            });
            //拒绝沟通
            $('#bt_list_refuseCommit').click(function(){
                if(xhExtra.buttonDisabled($(this))) return false;
                $this.funObj().refuseCommit();
            });
            //录入确认
            $('#bt_list_checkTypeIn').click(function(){
                if(xhExtra.buttonDisabled($(this))) return false;
                $this.funObj().checkTypeIn();
            });
            //导出
            $('#bt_list_export').click(function () {
                $this.funObj().exportData();
            });
            //教师统计
            $('#bt_list_teaStat').click(function(){
                $this.funObj().teaStat();
            });
            //使用情况
            $('#bt_list_showDetail').click(function(){
                $this.funObj().showDetail();
            });
        },
        funObj: function () {
            var $this = this;
            return {
                //查找
                search: function (_return) {
                    var _params = {
                        search: {
                            vague: xhExtra.getValue($('#list_vague')),
                            status: xhExtra.getValue($('#list_search_status')),
                            publish: xhExtra.getValue($('#list_search_publish')),
                            plan: xhExtra.getValue($('#list_search_plan')),
                            existId: xhExtra.getValue($('#list_search_existId')),
                            bookSubject: xhExtra.getValue($('#list_search_bookSubject')),
                            bookClass: xhExtra.getValue($('#list_search_bookClass')),
                            bookType: xhExtra.getValue($('#list_search_bookType')),
                            app: xhExtra.getValue($('#list_search_app')),
                            school_area: $('#school_area').combotree('getValue'),
                            searchType: xhExtra.getValue($('#list_search_type')),
                            refuseHandle: xhExtra.getValue($('#list_search_refuseHandle')),
                            complete: xhExtra.getValue($('#list_search_bookComplete')),
                            applySubject: xhExtra.getValue($('#list_search_applySubject')),
                            applyClass: xhExtra.getValue($('#list_search_applyClass')),
                            applyVolume: xhExtra.getValue($('#list_search_applyVolume')),
                            searchStartDate: $('#list_search_startTime').getElementValue(false),
                            searchEndDate: $('#list_search_endTime').getElementValue(false)
                        }
                    };
                    if (_return) {
                        return _params.search;
                    }
                    $this.dataGrid.reload(_params)
                },
                // //增加
                // addApply: function () {
                //     window.top.xhTop.showModal({
                //         title: '添加教辅申请',
                //         content: xhTool.getFrameString('reference/addReferenceApply', {}, 350),
                //         button: '保存',
                //         size: 'sm',
                //         width:'600'
                //     });
                // },
                //审核
                setReferenceCheck: function (level) {
                    var id = $this.dataGrid.getSelectValues('iId');
                    var iStatus = $this.dataGrid.getSelectValue('iStatusName');
                    if (level === 1){//完成
                        if (id.length < 1) {
                            window.top.xhTop.showError('未选中记录！');
                            return false;
                        }
                        if (id.length > 1){
                            window.top.xhTop.showError('请单选后操作！');
                            return false;
                        }
                        if (iStatus === '完成'){
                            window.top.xhTop.showError('该项已审核完成，请重新选择');
                            return false;
                        }
                        id = $this.dataGrid.getSelectValue('iId');
                        var sBookName = $this.dataGrid.getSelectValue('sBookName');
                        var iBookId = $this.dataGrid.getSelectValue('iBookId');
                        var char = '';
                        char = '<div>' +
                            '书名：<input id="swal-input1" class="swal2-input" value="'+ sBookName + '">' +
                            '书id：<input id="swal-input2" class="swal2-input" value="'+ iBookId + '">' +
                            '审核说明：<textarea type="text" id="note" class="swal2-textarea" placeholder="选填"></textarea>' +
                            '</div>';
                        window.top.swal({
                            showCancelButton: true,
                            confirmButtonText: '确认',
                            cancelButtonText: '取消',
                            showLoaderOnConfirm: true,
                            allowOutsideClick: false,
                            title: '确认信息',
                            width: 500,
                            padding: 10,
                            html: char,
                            preConfirm: function() {
                                return new Promise(function (resolve, reject) {
                                    var sBookName     = $('#swal-input1', window.top.document).val();
                                    var iBookId     = $('#swal-input2', window.top.document).val();
                                    var note     = $('#note', window.top.document).val();
                                    if(sBookName < 1 || iBookId < 1){
                                        reject('所填内容不能为空');
                                    } else {
                                        xhExtra.ajaxRequest('res/setFinishStatus', {
                                            id: id,
                                            bookName: sBookName,
                                            bookId: iBookId,
                                            note: note
                                        }, {success: true});
                                        $this.dataGrid.reload();
                                    }
                                })
                            }
                        })
                    } else if(level === 2){//拒绝
                        if (id.length < 1) {
                            window.top.xhTop.showError('未选中记录！');
                            return false;
                        }
                        if (id.length > 1){
                            window.top.xhTop.showError('请单选后操作！');
                            return false;
                        }
                        if (iStatus === '完成' || iStatus === '拒绝'){
                            window.top.xhTop.showError('该状态不允许此操作，请重新选择');
                            return false;
                        }
                        id = $this.dataGrid.getSelectValue('iId');
                        window.top.swal({
                            showCancelButton: true,
                            confirmButtonText: '确认',
                            cancelButtonText: '取消',
                            showLoaderOnConfirm: true,
                            allowOutsideClick: false,
                            title: '填写原因',
                            html: '<div><textarea type="text" id="reason" class="swal2-textarea" placeholder="必填"></textarea></div>',
                            preConfirm: function() {
                                return new Promise(function (resolve, reject) {
                                    var reason     = $('#reason', window.top.document).val();
                                    if(reason < 1){
                                        reject('内容不能为空');
                                    } else {
                                        xhExtra.ajaxRequest('res/setRefuseStatus', {
                                            id: id,
                                            refuseReason: reason
                                        }, {success: true});
                                        resolve();
                                        $this.dataGrid.reload();
                                    }
                                })
                            }
                        })
                    } else if(level === 3){//需录入
                        if (id.length < 1) {
                            window.top.xhTop.showError('未选中记录！');
                            return false;
                        }
                        window.top.swal({
                            showCancelButton: true,
                            confirmButtonText: '确认',
                            cancelButtonText: '取消',
                            showLoaderOnConfirm: true,
                            allowOutsideClick: false,
                            html: '推荐书名<input id="recommend" class="swal2-input" placeholder="选填">',
                            preConfirm: function() {
                                return new Promise(function (resolve, reject) {
                                    var recommendBook     = $('#recommend', window.top.document).val();
                                    xhExtra.ajaxRequest('res/setWriteStatus', {
                                        id: id,
                                        recommendBook: recommendBook
                                    }, {success: true});
                                    resolve();
                                    $this.dataGrid.reload();
                                })
                            }
                        })
                        // xhExtra.askChangeStatus('res/setWriteStatus', {id: id}, $this.dataGrid, '确认吗？');
                    } else if(level === 4){//待定
                        var iStatusName = $this.dataGrid.getSelectValues('iStatusName');
                        var check = false;
                        if (id.length < 1) {
                            window.top.xhTop.showError('未选中记录！');
                            return false;
                        }
                        iStatusName.forEach(function(name) {
                            if (name !== '待审核'){
                                check = true;
                            }
                        });
                        if (check){
                            window.top.xhTop.showError('所选存在不可操作状态，请重新选择后操作!');
                            return false;
                        }
                        window.top.swal({
                            showCancelButton: true,
                            confirmButtonText: '确认',
                            cancelButtonText: '取消',
                            showLoaderOnConfirm: true,
                            allowOutsideClick: false,
                            title: '填写原因',
                            html: '<div><textarea type="text" id="resion" class="swal2-textarea" placeholder="必填"></textarea></div>',
                            preConfirm: function() {
                                return new Promise(function (resolve, reject) {
                                    var reason     = $('#resion', window.top.document).val();
                                    if(reason < 1){
                                        reject('内容不能为空');
                                    } else {
                                        xhExtra.ajaxRequest('res/confirmReference', {
                                            id: id,
                                            reason: reason
                                        }, {success: true});
                                        resolve();
                                        $this.dataGrid.reload();
                                    }
                                })
                            }
                        });
                        // xhExtra.askChangeStatus('res/confirmReference', {id: id}, $this.dataGrid, '是否将状态改为待定？');
                    } else if(level === 5){//已上架
                        if (id.length < 1) {
                            window.top.xhTop.showError('未选中记录！');
                            return false;
                        }
                        iStatusName = $this.dataGrid.getSelectValues('iStatusName');
                        check = false;
                        iStatusName.forEach(function(name) {
                            if (name !== '资料准备中'){
                                check = true;
                            }
                        });
                        if (check){
                            window.top.xhTop.showError('仅状态[资料准备中]可操作，请重新选择!');
                            return false;
                        }
                        xhExtra.askChangeStatus('res/setPutAway', {id: id}, $this.dataGrid, '是否将状态改为已上架？');
                    }
                },
                repeal: function () {
                    var id = $this.dataGrid.getSelectValues('iId');
                    if (id.length < 1) {
                        window.top.xhTop.showError('未选中记录！');
                        return false;
                    }
                    xhExtra.askChangeStatus('res/repealConnectTea', {id: id}, $this.dataGrid, '确认撤销关联老师吗？');
                },
                delApply: function () {
                    var id = $this.dataGrid.getSelectValues('iId');
                    var iStatusName = $this.dataGrid.getSelectValues('iStatusName');
                    var iCreateUserId = $this.dataGrid.getSelectValues('iCreateUserId');
                    var userId = $('#userId_data').val();
                    var check = false;
                    var canDel = false;
                    if (id.length < 1) {
                        window.top.xhTop.showError('未选中记录！');
                        return false;
                    }

                    iStatusName.forEach(function(name) {
                        if (name !== '待审核' && name !== '待定'){
                            check = true;
                        }
                    });
                    if (check){
                        window.top.xhTop.showError('所选存在不可取消项，请重新选择!');
                        return false;
                    }

                    iCreateUserId.forEach(function(user_id) {
                        if (user_id !== userId){//不是创建者
                            canDel = true;
                        }
                    });
                    if (canDel){
                        window.top.xhTop.showError('所选存在你没有权限操作的数据，请重新选择!');
                        return false;
                    }
                    xhExtra.askChangeStatus('res/delReferApply', {id: id}, $this.dataGrid, '确认取消？');
                },
                showProgress: function () {
                    var iBookId = $this.dataGrid.getSelectValue('iBookId');
                    var host = $this.dataGrid.getSelectValue('host');
                    if (!iBookId) {
                        window.top.xhTop.showError('不存在书id,不可查看');
                        return false;
                    }
                    window.top.xhTop.showModal({
                        width:'800',
                        title:'查看进度',
                        content: '<iframe src="'+host+'/Cloudwk/getBookCatelog?bookId='+iBookId+'"  style="width: 100%;;border-style: none;padding: 0px;height:520px"  scrolling="yes"   ></iframe>'
                    });
                },
                planApply: function () {
                    var id = $this.dataGrid.getSelectValue('iId');
                    var iBookId = $this.dataGrid.getSelectValue('iBookId');
                    var sBookName = $this.dataGrid.getSelectValue('sBookName');
                    if (!iBookId) {
                        window.top.xhTop.showError('不存在书id,不可申请');
                        return false;
                    }

                    window.top.xhTop.showModal({
                        title: '[排期申请]书：' + sBookName,
                        id: 'apply_form',
                        footerHtml:
                        '<button type="button" class="btn btn-primary xh-btn-load" id="apply_plan_confirm">提交</button>' +
                        '<button type="button" class="btn btn-default" data-dismiss="modal" id="bt_modal_close">关闭</button>',
                        content: xhTool.getFrameString('res/addPlanApplyForm', {type:1, id: id, bookId: iBookId, bookName: sBookName}, 300),
                        size: 'md',
                        width:'800',
                        backClose: false
                    });
                    // window.top.xhTop.createNewTab('排期申请：' + sBookName, 'res/addPlanApplyForm?id='+id+'&bookId='+iBookId+'&bookName='+sBookName);
                },
                planDetail: function () {
                    var id = $this.dataGrid.getSelectValue('iId');
                    var iBookId = $this.dataGrid.getSelectValue('iBookId');
                    var sBookName = $this.dataGrid.getSelectValue('sBookName');
                    if (!iBookId) {
                        window.top.xhTop.showError('不存在书id,不可操作');
                        return false;
                    }
                    var footStr = '<button type="button" class="btn btn-default" data-dismiss="modal" id="bt_modal_close">关闭</button>';
                    if (addPower) {
                        footStr = '<button type="button" class="btn btn-primary xh-btn-load" id="plan_form_confirm">保存</button>' +footStr;
                    }
                    window.top.xhTop.showModal({
                        title: '【排期计划】编号：' + id + '，书名：' + sBookName,
                        id: 'plan_form',
                        footerHtml:footStr,
                        content: xhTool.getFrameString('res/applyPlanDetail', {type:1, id: id, bookId: iBookId}, $(window).height()-100),
                        size: 'lg',
                        backClose: false
                    });
                },
                refreshPublish: function () {
                    var id = $this.dataGrid.getSelectValues('iId');
                    // if (id.length < 1) {
                    //     type = 1;//刷新全部
                    //     msg = '刷新全部书本录入状态？';
                    // } else {
                    //     msg = '刷新所选'+id.length+'本书的录入状态？';
                    // }
                    // xhExtra.askChangeStatus('res/refreshPublishStatus', {type: type, id: id}, $this.dataGrid, msg);

                    window.top.swal({
                        showCancelButton: true,
                        confirmButtonText: '确认',
                        cancelButtonText: '取消',
                        showLoaderOnConfirm: true,
                        allowOutsideClick: false,
                        title: '选择刷新范围',
                        html: '<div align="left" style="margin-left: 70px">' +
                        '<label style="font-size: initial"><input type="radio" name ="scope" value="1" align="left" checked>所选书本</label><br>' +
                        '<label style="font-size: initial"><input type="radio" name ="scope" value="2" align="left">全部书本</label><br>' +
                        '<label style="font-size: initial"><input type="radio" name ="scope" value="3" align="left">当前查找筛选结果</label>' +
                        "<label>（注：以上操作仅刷新书本的“录入状态”和“完成状态”）</label>" +
                        '</div>',
                        preConfirm: function() {
                            return new Promise(function (resolve, reject) {
                                var scope = $("input[name='scope']:checked", window.top.document).val();
                                if (scope === '1') {
                                    if (id.length < 1) {
                                        reject('没有选择书本，请选择后操作');
                                        return false;
                                    }
                                    xhExtra.ajaxRequest('res/refreshPublishStatus', {
                                        id: id,
                                        type: scope
                                    }, {success: true,check: true, async: false},function(result) {
                                        $this.dataGrid.reload();
                                    });
                                } else if (scope === '3') {
                                    post_params = {
                                        vague: xhExtra.getValue($('#list_vague')),
                                        status: xhExtra.getValue($('#list_search_status')),
                                        publish: xhExtra.getValue($('#list_search_publish')),
                                        plan: xhExtra.getValue($('#list_search_plan')),
                                        existId: xhExtra.getValue($('#list_search_existId')),
                                        bookSubject: xhExtra.getValue($('#list_search_bookSubject')),
                                        bookClass: xhExtra.getValue($('#list_search_bookClass')),
                                        bookType: xhExtra.getValue($('#list_search_bookType')),
                                        app: xhExtra.getValue($('#list_search_app')),
                                        school_area: $('#school_area').combotree('getValue'),
                                        searchType: xhExtra.getValue($('#list_search_type')),
                                        refuseHandle: xhExtra.getValue($('#list_search_refuseHandle')),
                                        complete: xhExtra.getValue($('#list_search_bookComplete')),
                                        applySubject: xhExtra.getValue($('#list_search_applySubject')),
                                        applyClass: xhExtra.getValue($('#list_search_applyClass')),
                                        applyVolume: xhExtra.getValue($('#list_search_applyVolume'))
                                    };
                                    xhExtra.ajaxRequest('res/refreshPublishStatus', {
                                        type: scope,
                                        params: post_params
                                    }, {success: true, async: false},function(result) {
                                        $this.dataGrid.reload();
                                    });
                                } else  {
                                    xhExtra.ajaxRequest('res/refreshPublishStatus', {
                                        type: scope
                                    }, {success: true, async: false},function(result) {
                                        $this.dataGrid.reload();
                                    });
                                }
                            })
                        }
                    });


                },
                checkData: function (startTime, endTime) {
                    if (startTime.length > 0 && endTime.length > 0) {
                        var startTmp = startTime.split("-");
                        var endTmp = endTime.split("-");
                        var sd = new Date(startTmp[0], startTmp[1], startTmp[2]);
                        var ed = new Date(endTmp[0], endTmp[1], endTmp[2]);
                        if (sd.getTime() > ed.getTime()) {
                            return false;
                        }
                    }
                    return true;
                },
                refuseHandle: function () {
                    var id = $this.dataGrid.getSelectValue('iId');
                    var iStatus = $this.dataGrid.getSelectValue('iStatusName');
                    var refuseHandle = $this.dataGrid.getSelectValue('refuseHandleName');
                    var reason = '';
                    if (!id) {
                        window.top.xhTop.showError('请选择后操作!');
                        return false;
                    }
                    if (iStatus === '拒绝' && (refuseHandle === '处理中' || refuseHandle === null)) {
                        window.top.swal({
                            title: '是否同意拒绝？',
                            showCancelButton: true,
                            confirmButtonText: '不同意',
                            cancelButtonText: '同意',
                            allowOutsideClick: true,
                            showCloseButton: true,
                            showLoaderOnConfirm: true,
                            confirmButtonColor: "#AAAAAA",
                            cancelButtonColor: "#3085D6",
                            html: '<div>' +
                            '<label style="font-size: large">填写相关原因</label>' +
                            '<textarea type="text" id="reason" class="swal2-textarea" placeholder="选填，不同意时必填">' +
                            '</textarea>' +
                            '</div>',
                            preConfirm: function() {
                                return new Promise(function (resolve, reject) {
                                    reason = $('#reason', window.top.document).val();
                                    if(reason < 1){
                                        reject('内容不能为空');
                                    } else {//不同意
                                        xhExtra.ajaxRequest('res/dealRefuseHandle', {
                                            id: id,
                                            reason: reason,
                                            type: 2
                                        }, {success: true});
                                        resolve();
                                        $this.dataGrid.reload();
                                    }
                                })
                            }
                        }).then(function(isConfirm) {
                            // 点击确认后的操作
                        },function(dismiss) {//同意
                            if (dismiss === 'cancel') {
                                reason = $('#reason', window.top.document).val();
                                xhExtra.ajaxRequest('res/dealRefuseHandle',{id: id, reason: reason, type: 1},{},function (res) {
                                    $this.dataGrid.reload();
                                    window.top.xhTop.showSuccess(res.msg);
                                });
                            }
                        });
                    } else {
                        window.top.xhTop.showError('当前状态不可进行此操作!');
                        return false;
                    }
                },
                refuseCommit: function () {
                    var id = $this.dataGrid.getSelectValue('iId');
                    var iStatus = $this.dataGrid.getSelectValue('iStatusName');
                    var refuseHandle = $this.dataGrid.getSelectValue('refuseHandleName');
                    if (!id) {
                        window.top.xhTop.showError('请选择后操作!');
                        return false;
                    }
                    var footerHtml = '<div></div>';
                    if (commitEditPower && refuseHandle === '待沟通') {//有编辑权限
                        footerHtml = '<div>' +
                            '<div >' +
                            '<button type="button" class="btn btn-primary xh-btn-load" id="bt_modal_confirm">确定</button>' +
                            '<button type="button" class="btn btn-default" data-dismiss="modal" id="bt_modal_close">关闭</button>' +
                            '</div>' +
                            '</div>';
                    }
                    if (iStatus === '拒绝') {
                        window.top.xhTop.showModal({
                            title: '拒绝沟通相关内容',
                            content: xhTool.getFrameString('res/dealRefuseCommit', {id: id}, 610),
                            button: '保存',
                            size: 'md',
                            width: '800',
                            backClose: false,
                            footerHtml:footerHtml
                        });
                    } else {
                        window.top.xhTop.showError('当前状态不可进行此操作!');
                        return false;
                    }
                },
                checkTypeIn: function () {
                    var id = $this.dataGrid.getSelectValue('iId');
                    window.top.xhTop.showModal({
                        title: '教辅录入确认',
                        content: xhTool.getFrameString('res/checkTypeIn', {id: id}, 650),
                        size: 'md',
                        width: '800',
                        backClose: false
                    });
                },
                exportData: function () {
                    window.top.swal({
                        title: '确认导出？',
                        text:'导出数据量过大可能会导出不成功，建议每次不超过八千条',
                        showCancelButton: true,
                        cancelButtonText: '取消',
                        confirmButtonText: '确认',
                        allowOutsideClick: true,
                        showCloseButton: true,
                        showLoaderOnConfirm: true,
                        type: 'warning',
                        preConfirm: function() {
                            return new Promise(function (resolve, reject) {
                                window.top.xhTop.showMessage({type:'success',title:'已执行导出', text:'请检查是否导出到本地，当前请勿其他操作；若时间过长导出不成功，请刷新页面适当减少数据量后重新导出'});
                                location.href = baseUrl + 'Res/exportReferenceApply?' + xhTool.parseParam($this.funObj().search(true));
                            })
                        }
                    }).then(function(isConfirm) {}, function(dismiss) {});
                    // location.href = baseUrl + 'Res/exportReferenceApply?' + xhTool.parseParam($this.funObj().search(true));
                },
                teaStat: function () {
                    window.top.xhTop.createNewTab('教师申请教辅统计','res/teaStat');
                },
                showDetail: function () {
                    var iBookId = $this.dataGrid.getSelectValue('iBookId');
                    var bookNme = $this.dataGrid.getSelectValue('sBookName');
                    var schoolId = $this.dataGrid.getSelectValue('iSchoolId');
                    if (!iBookId) {
                        window.top.xhTop.showError('不存在书id,不可查看');
                        return false;
                    }
                    window.top.xhTop.showModal({
                        title: bookNme + '-使用情况查询:',
                        content: xhTool.getFrameString('Res/showDetailInfo', {bookId: iBookId, schoolId: schoolId}, 500),
                        size: 'md',
                        width: 800
                    });
                }
            }
        }
    }
}

